{if condition="$instance['instancestatus'] neq 0"}
<style>
    .flowcontent input {
        pointer-events: none;
        border: 1px solid #DDD;
        background-color: #F5F5F5;
    }

    .flowcontent select {
        pointer-events: none;
        border: 1px solid #DDD;
        background-color: #F5F5F5;
    }

    .flowcontent textarea {
        pointer-events: none;
        border: 1px solid #DDD;
        background-color: #F5F5F5;
    }

</style>
{/if}
<div class="layui-form" lay-filter="layuiadmin-form-admin" id="layuiadmin-form-admin" style="padding: 20px 30px 0 0;">
    <input type="hidden" id="taskid" name="taskid" value="{$task->id ?? ''}" required autocomplete="off"
           class="layui-input" disabled>
    <input type="hidden" id="ids" name="ids" value="{$ids ?? ''}" required autocomplete="off"
           class="layui-input" disabled>
    <input type="hidden" id="flowcode" name="flowcode" value="{$flowCode ?? ''}" required autocomplete="off"
           class="layui-input" disabled>
    <input type="hidden" id="table" name="table" value="{$table ?? ''}" required autocomplete="off"
           class="layui-input" disabled>
    <div id="dyhtml">


    <div class="layui-form-item">
        <label class="layui-form-label">申请人</label>
        <div class="layui-input-block">
            <input type="text" value="{$originator->nickname ?? ''}" required placeholder="申请人" autocomplete="off"
                   class="layui-input" disabled>
        </div>
    </div>
    {if $model.typeName.name eq '用章'}

    {elseif $model.typeName.name eq '借款'}
    <div class="layui-col-xs6 layui-col-sm6 layui-col-md4">
        <div class="layui-form-item ">
            <label class="layui-form-label">借款金额</label>
            <div class="layui-input-block">
                <input type="text" value="  {$model.type_name ?? ''}元" required placeholder="借款金额"
                       autocomplete="off"
                       class="layui-input" disabled>
            </div>
        </div>
    </div>
    <div class="layui-col-xs6 layui-col-sm6 layui-col-md4">
        <div class="layui-form-item ">
            <label class="layui-form-label">金额(大写)</label>
            <div class="layui-input-block">
                <input type="text" value="{$model.dx ?? ''}" required placeholder="借款金额(大写)"
                       autocomplete="off"
                       class="layui-input" disabled>
            </div>
        </div>
    </div>
    <div class="layui-col-xs6 layui-col-sm6 layui-col-md4">
        <div class="layui-form-item ">
            <label class="layui-form-label">借款方式</label>
            <div class="layui-input-block">
                <input type="text" value="转账" required placeholder="借款方式"
                       autocomplete="off"
                       class="layui-input" disabled>
            </div>
        </div>
    </div>
    <div class="layui-col-xs6 layui-col-sm6 layui-col-md4">
        <div class="layui-form-item ">
            <label class="layui-form-label">收款名称</label>
            <div class="layui-input-block">
                <input type="text" value="  {$model.username ?? ''}" required placeholder="收款名称"
                       autocomplete="off"
                       class="layui-input" disabled>
            </div>
        </div>
    </div>
    <div class="layui-col-xs6 layui-col-sm6 layui-col-md4">
        <div class="layui-form-item ">
            <label class="layui-form-label">收款账号</label>
            <div class="layui-input-block">
                <input type="text" value="工资卡" required placeholder="收款账号"
                       autocomplete="off"
                       class="layui-input" disabled>
            </div>
        </div>
    </div>
    <div class="layui-col-xs6 layui-col-sm6 layui-col-md4">
        <div class="layui-form-item ">
            <label class="layui-form-label">开户行</label>
            <div class="layui-input-block">
                <input type="text" value="" required placeholder="开户行"
                       autocomplete="off"
                       class="layui-input" disabled>
            </div>
        </div>
    </div>
    <div class="layui-col-xs12 layui-col-sm12 layui-col-md12">
        <div class="layui-form-item ">
            <label class="layui-form-label">借款用途</label>
            <div class="layui-input-block">
                <textarea class="layui-textarea" disabled>{$model.content ?? ''}</textarea>
            </div>
        </div>
    </div>
    {elseif $model.typeName.name eq '用车'}
<!--    <div class="layui-col-xs12 layui-col-sm12 layui-col-md12">-->
<!--        <div class="layui-form-item ">-->
<!--            <label class="layui-form-label">车辆信息</label>-->
<!--            <div class="layui-input-block">-->
<!--                <table class="layui-table">-->
<!--                    <thead>-->
<!--                    <tr>-->
<!--                        <th style="text-align: center;">起始地点</th>-->
<!--                        <th style="text-align: center;">计划线路</th>-->
<!--                        <th style="text-align: center;">开始时间</th>-->
<!--                        <th style="text-align: center;">结束时间</th>-->
<!--                        <th style="text-align: center;">用车天数</th>-->
<!--                        <th style="text-align: center;">司机姓名</th>-->
<!--                        <th style="text-align: center;">司机号码</th>-->
<!--                        <th style="text-align: center;">用车人</th>-->

<!--                    </tr>-->
<!--                    </thead>-->
<!--                    <tbody>-->
<!--                    {foreach $model.che as $key=>$value}-->
<!--                    <tr>-->
<!--                        <td>-->
<!--                            {$value.start_address ?? ''}-->
<!--                        </td>-->
<!--                        <td style="text-align: center;">-->
<!--                            {$value.plan_lx ?? ''}-->
<!--                        </td>-->
<!--                        <td style="text-align: center;">{$value.start_time ?? ''}</td>-->
<!--                        <td>-->
<!--                            {$value.end_time ?? ''}-->
<!--                        </td>-->
<!--                        <td style="text-align: center;">-->
<!--                            {$value.day ?? ''}-->
<!--                        </td>-->
<!--                        <td style="text-align: center;">{$value.sj_name ?? ''}</td>-->
<!--                        <td>-->
<!--                            {$value.sj_phone ?? ''}-->
<!--                        </td>-->

<!--                        <td style="text-align: center;">{$value.ycr ?? ''}</td>-->
<!--                    </tr>-->
<!--                    {/foreach}-->
<!--                    </tbody>-->
<!--                </table>-->
<!--            </div>-->
<!--        </div>-->
<!--    </div>-->
    {elseif $model.typeName.name eq '采购'}
<!--    <div class="layui-col-xs12 layui-col-sm12 layui-col-md12">-->
<!--        <div class="layui-form-item ">-->
<!--            <label class="layui-form-label">采购信息</label>-->
<!--            <div class="layui-input-block">-->
<!--                <table class="layui-table">-->
<!--                    <thead>-->
<!--                    <tr>-->
<!--                        <th style="text-align: center;">品名规格</th>-->
<!--                        <th style="text-align: center;">数量</th>-->
<!--                        <th style="text-align: center;">备注</th>-->

<!--                    </tr>-->
<!--                    </thead>-->
<!--                    <tbody id="index-table">-->
<!--                    {foreach $model.caigou as $key=>$value}-->
<!--                    <tr>-->
<!--                        <td>-->
<!--                            {$value.cg_guige ?? ''}-->
<!--                        </td>-->
<!--                        <td style="text-align: center;">-->
<!--                            {$value.cg_num ?? ''}-->
<!--                        </td>-->
<!--                        <td style="text-align: center;">{$value.content ?? ''}</td>-->
<!--                    </tr>-->
<!--                    {/foreach}-->
<!--                    </tbody>-->
<!--                </table>-->
<!--            </div>-->
<!--        </div>-->
<!--    </div>-->
    {/if}
    {if condition="$instance['instancestatus'] neq 2"}
    <div class="layui-form-item">
        <label class="layui-form-label">审批意见1</label>
        <div class="layui-input-block">
            <textarea id="comment" class="layui-textarea" data-use-current="true" name="comment"></textarea>
        </div>
    </div>
    {/if}
    <div class="layui-form-item">
        <label class="layui-form-label">审批历史</label>
        <div class="layui-input-block">
            <table class="layui-table" lay-size="sm">
                <thead>
                <tr>
                    <td>审批人</td>
                    <td>审批步骤</td>
                    <td>审批意见</td>
                    <td>审批时间</td>
                </tr>
                </thead>
                <tbody>
                {volist name="history" id="vo" }
                <tr>
                    <td>{$vo.nickname}</td>
                    <td>{$vo.stepname}</td>
                    <td>{$vo.comment}</td>
                    <td>{$vo.completedtime}</td>
                </tr>
                {/volist}
                </tbody>
            </table>
        </div>
    </div>
    </div>
    <div class="form-group layer-footer">
        <label class="control-label col-xs-12 col-sm-2"></label>
        <div class="layui-input-block">

            {if condition="$mode neq 'view'"}
                 {if condition="$instance['instancestatus'] eq 0"}
                     <button type="button" id='start' class="layui-btn">提交</button>

                {elseif condition="$instance['instancestatus'] eq 1"/}
                <button type="submit" id='agree' class="layui-btn btn-success btn-embossed disabled" style="background-color: #18bc9c !important; border-radius: 5px;">同意</button>
                <button type="submit" id='refuse' class="layui-btn btn-danger btn-embossed disabled" style="background-color: #e74c3c !important; border-radius: 5px;">拒绝</button>
                {else/}
                {/if}
            {/if}
<!--            {if condition="$instance['instancestatus'] neq 2 && $instance['instancestatus'] neq 3 && $instance['originator'] eq $auth->id"}-->
<!--            <button type="submit" id='cancel' class="layui-btn btn-danger btn-embossed disabled"style="background-color: #e74c3c !important; border-radius: 5px;">取消</button>-->
<!--            {/if}-->
            <button type="button" id='flowchart' class="layui-btn layui-btn-warm btn-embossed"
                    style="background-color: #f39c12 !important; border-radius: 5px;">流程图
            </button>
            <button type="button" id='dy' class="layui-btn layui-btn-warm btn-embossed"
                    style="background-color: #f39c12 !important; border-radius: 5px;">打印
            </button>
        </div>
    </div>
</div>
<script src="/static/markdown/js/jquery.min.js"></script>
<script src="/static/admin/layui/layui.js"></script>
<script src="/static/admin/js/jquery.PrintArea.js"></script>
<script>
    var url = "{:url('Myworkitem/flowchart')}", edit = "{:url('Myworkitem/edit')}",
        refuse = "{:url('Myworkitem/refuse')}";
    layui.config({
        base: '/static/admin/' //静态资源所在路径
    }).extend({
        index: 'lib/index', //主入口模块
    }).use(['index', 'form', 'flow'], function () {
        var $ = layui.$, form = layui.form;
        var taskid = $('#taskid').val();
        var ids = $('#ids').val();
        var flowcode = $('#flowcode').val();
        var table = $('#table').val();
        var param = $.param({'taskid': taskid, 'ids': ids, 'flowcode': flowcode});
        $('#agree').on('click', function (res) {
            var comment = $('#comment').val();
            $.ajax({
                url: edit,
                type: "post",
                data: {
                    'taskid': taskid,
                    'ids': ids,
                    'flowcode': flowcode,
                    'table': table,
                    'comment': comment
                },
                beforeSend: function () {
                    layer.load(2, {
                        shade: [0.6, '#fff'], content: '数据提交中...', success: function (layero) {
                            layero.find('.layui-layer-content').css({
                                'padding-top': '6px',
                                'width': '150px',
                                'padding-left': '40px'
                            });
                            layero.find('.layui-layer-ico16, .layui-layer-loading .layui-layer-loading2').css({
                                'width': '150px !important',
                                'background-position': '2px 0 !important'
                            });
                        }
                    });
                },
                success: function (res) {
                    if (res.code === 200) {
                        layer.msg(res.msg, {icon: 1});
                        var index = parent.layer.getFrameIndex(window.name); //获取当前窗口的name
                        parent.layer.close(index);		//关闭窗口
                        window.parent.location.reload();
                    } else {
                        layer.msg(res.msg, {icon: 5});
                        return false;
                    }
                }
            });
        });
        $('#refuse').on('click', function (res) {
            var comment = $('#comment').val();
            $.ajax({
                url: refuse,
                type: "post",
                data: {
                    'taskid': taskid,
                    'ids': ids,
                    'flowcode': flowcode,
                    'table': table,
                    'comment': comment
                },
                beforeSend: function () {
                    layer.load(2, {
                        shade: [0.6, '#fff'], content: '数据提交中...', success: function (layero) {
                            layero.find('.layui-layer-content').css({
                                'padding-top': '6px',
                                'width': '150px',
                                'padding-left': '40px'
                            });
                            layero.find('.layui-layer-ico16, .layui-layer-loading .layui-layer-loading2').css({
                                'width': '150px !important',
                                'background-position': '2px 0 !important'
                            });
                        }
                    });
                },
                success: function (res) {
                    if (res.code === 200) {
                        layer.msg(res.msg, {icon: 1});
                        var index = parent.layer.getFrameIndex(window.name); //获取当前窗口的name
                        parent.layer.closeAll();		//关闭窗口
                        window.parent.location.reload();
                    } else {
                        layer.msg(res.msg, {icon: 5});
                        return false;
                    }
                }
            });
        });
        $('#flowchart').on('click', function (res) {
            layer.open({
                type: 2
                , title: "流程图"
                , content: url + '?' + param
                , area: ['70%', '70%']
                , maxmin: true
            });
        });
        $('#cancel').on('click', function (res) {
            console.log("取消");
        });
        $('#start').on('click', function (res) {
            console.log("提交");
        });
        $('#dy').on('click',function (res) {
            $("#dyhtml").printArea();
            return false; //阻止表单跳转。如果需要表单跳转，去掉这段即可。
        })
    });
</script>
